function loginvalidation(){
	var error = 0;
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	
	//Validate the username, the username should be an email
	if(document.login.username.value == ""){
		document.login.username.style.background = "#f37474";
		document.login.username.style.color = "#fff";
		document.login.username.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.login.username.style.background = "#ffffff";
		document.login.username.style.color = "#888D8F";
		document.login.username.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	//Validate the password
	if(document.login.loginpassword.value == "" || document.login.loginpassword.value.charAt(0) == " "){
		document.login.loginpassword.style.background = "#f37474";
		document.login.loginpassword.style.color = "#fff";
		document.login.loginpassword.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.login.loginpassword.style.background = "#ffffff";
		document.login.loginpassword.style.color = "#888D8F";
		document.login.loginpassword.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(error != 0){
		return false;
	} else {
		return true;
	}
}

function newslettervalidation(){
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	
	//Validate the subscribe email
	if(document.newsletter.subscribe.value == "" || reg.test(document.newsletter.subscribe.value) == false){
		document.newsletter.subscribe.style.background = "#f37474";
		document.newsletter.subscribe.style.color = "#fff";
		document.newsletter.subscribe.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		return false;
	} else {
		document.newsletter.subscribe.style.background = "#ffffff";
		document.newsletter.subscribe.style.color = "#888D8F";
		document.newsletter.subscribe.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
		return true;
	}
}

function student_validation(){
	var error = 0;
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	
	if(document.student.username.value == "" || document.student.username.value.charAt(0) == " "){
		document.student.username.style.background = "#f37474";
		document.student.username.style.color = "#fff";
		document.student.username.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.student.username.style.background = "#ffffff";
		document.student.username.style.color = "#888D8F";
		document.student.username.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.student.password.value == "" || document.student.password.value.charAt(0) == " "){
		document.student.password.style.background = "#f37474";
		document.student.password.style.color = "#fff";
		document.student.password.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.student.password.style.background = "#ffffff";
		document.student.password.style.color = "#888D8F";
		document.student.password.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.student.email.value == "" || reg.test(document.student.email.value) == false){
		document.student.email.style.background = "#f37474";
		document.student.email.style.color = "#fff";
		document.student.email.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.student.email.style.background = "#ffffff";
		document.student.email.style.color = "#888D8F";
		document.student.email.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.student.fname.value == "" || document.student.fname.value.charAt(0) == " "){
		document.student.fname.style.background = "#f37474";
		document.student.fname.style.color = "#fff";
		document.student.fname.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.student.fname.style.background = "#ffffff";
		document.student.fname.style.color = "#888D8F";
		document.student.fname.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.student.lname.value == "" || document.student.lname.value.charAt(0) == " "){
		document.student.lname.style.background = "#f37474";
		document.student.lname.style.color = "#fff";
		document.student.lname.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.student.lname.style.background = "#ffffff";
		document.student.lname.style.color = "#888D8F";
		document.student.lname.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.student.group_code.value == ""){
		document.student.group_code.style.background = "#f37474";
		document.student.group_code.style.color = "#fff";
		document.student.group_code.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.student.group_code.style.background = "#ffffff";
		document.student.group_code.style.color = "#888D8F";
		document.student.group_code.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(error != 0){
		return false;
	} else {
		return true;
	}
}

function teacher_validation(){
	var error = 0;
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	
	if(document.teacher.username.value == "" || document.teacher.username.value.charAt(0) == " "){
		document.teacher.username.style.background = "#f37474";
		document.teacher.username.style.color = "#fff";
		document.teacher.username.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.teacher.username.style.background = "#ffffff";
		document.teacher.username.style.color = "#888D8F";
		document.teacher.username.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.teacher.password.value == "" || document.teacher.password.value.charAt(0) == " "){
		document.teacher.password.style.background = "#f37474";
		document.teacher.password.style.color = "#fff";
		document.teacher.password.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.teacher.password.style.background = "#ffffff";
		document.teacher.password.style.color = "#888D8F";
		document.teacher.password.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.teacher.email.value == "" || reg.test(document.teacher.email.value) == false){
		document.teacher.email.style.background = "#f37474";
		document.teacher.email.style.color = "#fff";
		document.teacher.email.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.teacher.email.style.background = "#ffffff";
		document.teacher.email.style.color = "#888D8F";
		document.teacher.email.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.teacher.fname.value == "" || document.teacher.fname.value.charAt(0) == " "){
		document.teacher.fname.style.background = "#f37474";
		document.teacher.fname.style.color = "#fff";
		document.teacher.fname.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.teacher.fname.style.background = "#ffffff";
		document.teacher.fname.style.color = "#888D8F";
		document.teacher.fname.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.teacher.lname.value == "" || document.teacher.lname.value.charAt(0) == " "){
		document.teacher.lname.style.background = "#f37474";
		document.teacher.lname.style.color = "#fff";
		document.teacher.lname.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.teacher.lname.style.background = "#ffffff";
		document.teacher.lname.style.color = "#888D8F";
		document.teacher.lname.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(error != 0){
		return false;
	} else {
		return true;
	}
}

function developer_validation(){
	var error = 0;
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	
	if(document.developer.username.value == "" || document.developer.username.value.charAt(0) == " "){
		document.developer.username.style.background = "#f37474";
		document.developer.username.style.color = "#fff";
		document.developer.username.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.developer.username.style.background = "#ffffff";
		document.developer.username.style.color = "#888D8F";
		document.developer.username.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.developer.password.value == "" || document.developer.password.value.charAt(0) == " "){
		document.developer.password.style.background = "#f37474";
		document.developer.password.style.color = "#fff";
		document.developer.password.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.developer.password.style.background = "#ffffff";
		document.developer.password.style.color = "#888D8F";
		document.developer.password.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.developer.email.value == "" || reg.test(document.developer.email.value) == false){
		document.developer.email.style.background = "#f37474";
		document.developer.email.style.color = "#fff";
		document.developer.email.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.developer.email.style.background = "#ffffff";
		document.developer.email.style.color = "#888D8F";
		document.developer.email.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.developer.fname.value == "" || document.developer.fname.value.charAt(0) == " "){
		document.developer.fname.style.background = "#f37474";
		document.developer.fname.style.color = "#fff";
		document.developer.fname.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.developer.fname.style.background = "#ffffff";
		document.developer.fname.style.color = "#888D8F";
		document.developer.fname.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.developer.lname.value == "" || document.developer.lname.value.charAt(0) == " "){
		document.developer.lname.style.background = "#f37474";
		document.developer.lname.style.color = "#fff";
		document.developer.lname.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.developer.lname.style.background = "#ffffff";
		document.developer.lname.style.color = "#888D8F";
		document.developer.lname.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(error != 0){
		return false;
	} else {
		return true;
	}
}

function custom_validation(){
	var error = 0;
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	
	if(document.custom.username.value == "" || document.custom.username.value.charAt(0) == " "){
		document.custom.username.style.background = "#f37474";
		document.custom.username.style.color = "#fff";
		document.custom.username.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.custom.username.style.background = "#ffffff";
		document.custom.username.style.color = "#888D8F";
		document.custom.username.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.custom.password.value == "" || document.custom.password.value.charAt(0) == " "){
		document.custom.password.style.background = "#f37474";
		document.custom.password.style.color = "#fff";
		document.custom.password.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.custom.password.style.background = "#ffffff";
		document.custom.password.style.color = "#888D8F";
		document.custom.password.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.custom.email.value == "" || reg.test(document.custom.email.value) == false){
		document.custom.email.style.background = "#f37474";
		document.custom.email.style.color = "#fff";
		document.custom.email.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.custom.email.style.background = "#ffffff";
		document.custom.email.style.color = "#888D8F";
		document.custom.email.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.custom.fname.value == "" || document.custom.fname.value.charAt(0) == " "){
		document.custom.fname.style.background = "#f37474";
		document.custom.fname.style.color = "#fff";
		document.custom.fname.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.custom.fname.style.background = "#ffffff";
		document.custom.fname.style.color = "#888D8F";
		document.custom.fname.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.custom.lname.value == "" || document.custom.lname.value.charAt(0) == " "){
		document.custom.lname.style.background = "#f37474";
		document.custom.lname.style.color = "#fff";
		document.custom.lname.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.custom.lname.style.background = "#ffffff";
		document.custom.lname.style.color = "#888D8F";
		document.custom.lname.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(document.custom.group_code.value == ""){
		document.custom.group_code.style.background = "#f37474";
		document.custom.group_code.style.color = "#fff";
		document.custom.group_code.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
		error += 1;
	} else {
		document.custom.group_code.style.background = "#ffffff";
		document.custom.group_code.style.color = "#888D8F";
		document.custom.group_code.style.borderColor = "#B9B9B9 #CFCFCF #E4E4E4";
	}
	
	if(error != 0){
		return false;
	} else {
		return true;
	}
}

function falselogin(){
	document.login.username.style.background = "#f37474";
	document.login.username.style.color = "#fff";
	document.login.username.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
	document.login.loginpassword.style.background = "#f37474";
	document.login.loginpassword.style.color = "#fff";
	document.login.loginpassword.style.borderColor = "#c93535 #c93535 #c26c6c #c26c6c";
}